package com.tz.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Created by heziqian on 2016/10/21.
 */
@Entity
@Table(name = "ONLINE_BOOK")
public class Book implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5733009180609933142L;
	private Long bookId;//图书id
	private String bookName;//书名
	private String author;//作者
	private String publish;//出版社
	private Date publishDate;//出版日期
	private double price;//价格
	private String introduce;//简介
	private String imUrl;//图片链接
	private Category category;//种类
	private String state;//状态
	
	public Book() {
		super();
	}
	
	
	
	public Book(String bookName, String author, String publish,
			Date publishDate, double price, String introduce, String imUrl,
			Category category, String state) {
		super();
		this.bookName = bookName;
		this.author = author;
		this.publish = publish;
		this.publishDate = publishDate;
		this.price = price;
		this.introduce = introduce;
		this.imUrl = imUrl;
		this.category = category;
		this.state = state;
	}



	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "book_id")
	@SequenceGenerator(name = "book_id", sequenceName = "online_book_id")
	public Long getBookId() {
		return bookId;
	}
	public void setBookId(Long bookId) {
		this.bookId = bookId;
	}
	@Column
	public String getBookName() {
		return bookName;
	}
	public void setBookName(String bookName) {
		this.bookName = bookName;
	}
	@Column
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	@Column
	public String getPublish() {
		return publish;
	}
	public void setPublish(String publish) {
		this.publish = publish;
	}
	@Column
	@Temporal(TemporalType.DATE)
	public Date getPublishDate() {
		return publishDate;
	}
	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}
	@Column
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	@Column
	public String getIntroduce() {
		return introduce;
	}
	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}
	@Column
	public String getImUrl() {
		return imUrl;
	}
	public void setImUrl(String imUrl) {
		this.imUrl = imUrl;
	}
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinColumn(name="cate_id")
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}


    @Column
	public String getState() {
		return state;
	}



	public void setState(String state) {
		this.state = state;
	}



	@Override
	public String toString() {
		return "Book [bookId=" + bookId + ", bookName=" + bookName
				+ ", author=" + author + ", publish=" + publish
				+ ", publishDate=" + publishDate + ", price=" + price
				+ ", introduce=" + introduce + ", imUrl=" + imUrl + ", state="
				+ state + "]";
	}
	
	
	
	
	
}
